package com.commander;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.util.SparseArray;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.amap.api.maps.AMap;
import com.amap.api.maps.AMapException;
import com.amap.api.maps.CameraUpdateFactory;
import com.amap.api.maps.model.LatLng;
import com.amap.api.maps.model.Polyline;
import com.amap.api.navi.AMapNavi;
import com.amap.api.navi.AMapNaviListener;
import com.amap.api.navi.AMapNaviView;
import com.amap.api.navi.AMapNaviViewListener;
import com.amap.api.navi.AMapNaviViewOptions;
import com.amap.api.navi.ParallelRoadListener;
import com.amap.api.navi.enums.AMapNaviParallelRoadStatus;
import com.amap.api.navi.enums.PathPlanningStrategy;
import com.amap.api.navi.model.AMapCalcRouteResult;
import com.amap.api.navi.model.AMapLaneInfo;
import com.amap.api.navi.model.AMapModelCross;
import com.amap.api.navi.model.AMapNaviCameraInfo;
import com.amap.api.navi.model.AMapNaviCross;
import com.amap.api.navi.model.AMapNaviLocation;
import com.amap.api.navi.model.AMapNaviPath;
import com.amap.api.navi.model.AMapNaviRouteNotifyData;
import com.amap.api.navi.model.AMapNaviTrafficFacilityInfo;
import com.amap.api.navi.model.AMapServiceAreaInfo;
import com.amap.api.navi.model.AimLessModeCongestionInfo;
import com.amap.api.navi.model.AimLessModeStat;
import com.amap.api.navi.model.NaviInfo;
import com.amap.api.navi.model.NaviLatLng;
import com.amap.api.navi.model.RouteOverlayOptions;
import com.amap.api.navi.view.RouteOverLay;
import com.commander.BasePopup;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;


public class BaseActivity extends Activity implements AMapNaviListener, AMapNaviViewListener, ParallelRoadListener,View.OnClickListener {
    protected AMapNaviView mAMapNaviView;
    public static AMapNavi mAMapNavi;

    private int routeID = -1;

    private static final float ROUTE_UNSELECTED_TRANSPARENCY = 0.3F;
    private static final float ROUTE_SELECTED_TRANSPARENCY = 1F;
    public  AMapNaviLocation aMapNaviLocation;
    public static final List<NaviLatLng> sList = new ArrayList<NaviLatLng>();
    public static final List<NaviLatLng> eList = new ArrayList<NaviLatLng>();
    private int routeIndex;

    private Button mStartNaviButton;
    private LinearLayout mRouteLineLayoutOne, mRouteLinelayoutTwo, mRouteLineLayoutThree;
    private View mRouteViewOne, mRouteViewTwo, mRouteViewThree;
    private TextView mRouteTextStrategyOne, mRouteTextStrategyTwo, mRouteTextStrategyThree;
    private TextView mRouteTextTimeOne, mRouteTextTimeTwo, mRouteTextTimeThree;
    private TextView mRouteTextDistanceOne, mRouteTextDistanceTwo, mRouteTextDistanceThree;
    private TextView mCalculateRouteOverView;

    private SparseArray<RouteOverLay> routeOverlays = new SparseArray<RouteOverLay>();

    private void openAlertDialog() {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("路线切换"); // 设置弹窗标题
        builder.setMessage("这是一个简单的弹窗示例。"); // 设置弹窗消息

        // 设置弹窗确认按钮
        builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                // 在这里处理确定按钮点击事件
                dialog.dismiss(); // 关闭弹窗
            }
        });

        // 设置弹窗取消按钮
        builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                // 在这里处理取消按钮点击事件
                dialog.dismiss(); // 关闭弹窗
            }
        });

        // 创建并显示弹窗
        AlertDialog dialog = builder.create();
        dialog.show();
    }
    public Context context=this;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        initView();
        Intent intent =getIntent();
        var target =intent.getExtras().getBundle("target");
        var latitude=   target.getDouble("latitude");
        var longitude=   target.getDouble("longitude");
        try {
            mAMapNavi = AMapNavi.getInstance(getApplicationContext());
            mAMapNavi.addAMapNaviListener(this);
            mAMapNavi.addParallelRoadListener(this);
            mAMapNavi.setMultipleRouteNaviMode(true);
            mAMapNavi.setUseInnerVoice(true, true);
            eList.add(new NaviLatLng(latitude,longitude));
            //设置模拟导航的行车速度
        } catch (AMapException e) {
            e.printStackTrace();
        }
        mAMapNaviView.setOnMapLoadedListener(()->{
//            RouteOverLay routeOverLay= routeOverlays.get(0);
//            AMapNaviPath path =  routeOverLay.getAMapNaviPath();
//            NaviLatLng position =path.getCenterForPath();
//            mAMapNaviView.getMap().moveCamera(CameraUpdateFactory.newLatLng(new LatLng(position.getLatitude(),position.getLongitude())));

        });
        mAMapNaviView.getMap().setOnPolylineClickListener(new AMap.OnPolylineClickListener() {
            @Override
            public void onPolylineClick(Polyline polyline) {
                if (routeOverlays != null && routeOverlays.size() == 1){
                    return;
                }
                for(int i= 0;i<routeOverlays.size();i++){
                    RouteOverLay routeOverLay = routeOverlays.valueAt(i);
                    if(routeOverLay.getPolylineIdList().contains(polyline.getId())){
                        routeIndex=i;
                        routeOverLay.setTransparency(1.0f);
                        routeOverLay.setZindex(1);
                        mAMapNavi.selectRouteId(routeOverlays.keyAt(i));
                    }else{
                        routeOverLay.setTransparency(0.4f);
                        routeOverLay.setZindex(0);
                    }
                }
            }
        });
    }

    @Override
    protected void onResume() {
        super.onResume();
        mAMapNaviView.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
        mAMapNaviView.onPause();

//
//        停止导航之后，会触及底层stop，然后就不会再有回调了，但是讯飞当前还是没有说完的半句话还是会说完
//        mAMapNavi.stopNavi();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
            mAMapNaviView.onDestroy();
        // since 1.6.0 不再在naviview destroy的时候自动执行AMapNavi.stopNavi();请自行执行
        if (mAMapNavi!=null){
            mAMapNavi.stopNavi();
            mAMapNavi.destroy();
        }

    }

    @Override
    public void onInitNaviFailure() {
        Toast.makeText(this, "init navi Failed", Toast.LENGTH_SHORT).show();
    }
    @Override
    public void onInitNaviSuccess() {
        //初始化成功

    }

    @Override
    public void onStartNavi(int type) {
        mAMapNaviView.setShowMode(2);
//        AMapNaviViewOptions aMapNaviViewOptions= new AMapNaviViewOptions();
//        aMapNaviViewOptions.setLayoutVisible(true);
//        aMapNaviViewOptions.setAutoDisplayOverview(false);
//        mAMapNaviView.setViewOptions(aMapNaviViewOptions);
        //开始导航回调
    }

    @Override
    public void onTrafficStatusUpdate() {
        //
    }

    @Override
    public void onLocationChange(AMapNaviLocation location) {
        //当前位置回调
        if(aMapNaviLocation==null){
            sList.add(new NaviLatLng(location.getCoord().getLatitude(),location.getCoord().getLongitude()));
            mAMapNavi.calculateDriveRoute(sList ,eList,null, PathPlanningStrategy.DRIVING_MULTIPLE_ROUTES_DEFAULT);
        }
        aMapNaviLocation=location;
    }

    @Override
    public void onGetNavigationText(int type, String text) {
        //播报类型和播报文字回调
    }

    @Override
    public void onGetNavigationText(String s) {


    }

    @Override
    public void onEndEmulatorNavi() {
        //结束模拟导航
    }

    @Override
    public void onArriveDestination() {
        //到达目的地
    }

    @Override
    public void onCalculateRouteFailure(int errorInfo) {

    }

    @Override
    public void onReCalculateRouteForYaw() {
        //偏航后重新计算路线回调
    }

    @Override
    public void onReCalculateRouteForTrafficJam() {
        //拥堵后重新计算路线回调
    }

    @Override
    public void onArrivedWayPoint(int wayID) {
        //到达途径点
    }

    @Override
    public void onGpsOpenStatus(boolean enabled) {
        //GPS开关状态回调
    }

    @Override
    public void onNaviSetting() {
        //底部导航设置点击回调
//        openAlertDialog();
        BasePopup basePopup = new BasePopup(getBaseContext());
        basePopup.showPopupWindow();

    }

    @Override
    public void onNaviMapMode(int naviMode) {
        //导航态车头模式，0:车头朝上状态；1:正北朝上模式。
    }

    @Override
    public void onNaviCancel() {
        finish();
    }


    @Override
    public void onNaviTurnClick() {
        //转弯view的点击回调
    }

    @Override
    public void onNextRoadClick() {
        //下一个道路View点击回调
    }


    @Override
    public void onScanViewButtonClick() {
        //全览按钮点击回调
    }

    @Override
    public void updateCameraInfo(AMapNaviCameraInfo[] aMapCameraInfos) {

    }

    @Override
    public void onServiceAreaUpdate(AMapServiceAreaInfo[] amapServiceAreaInfos) {

    }

    @Override
    public void onNaviInfoUpdate(NaviInfo naviinfo) {
        //导航过程中的信息更新，请看NaviInfo的具体说明
    }

    @Override
    public void OnUpdateTrafficFacility(AMapNaviTrafficFacilityInfo aMapNaviTrafficFacilityInfo) {
        //已过时
    }

    @Override
    public void showCross(AMapNaviCross aMapNaviCross) {
        //显示放大图回调
    }

    @Override
    public void hideCross() {
        //隐藏放大图回调
    }

    @Override
    public void showLaneInfo(AMapLaneInfo[] laneInfos, byte[] laneBackgroundInfo, byte[] laneRecommendedInfo) {
        //显示车道信息

    }

    @Override
    public void hideLaneInfo() {
        //隐藏车道信息
    }

    @Override
    public void onCalculateRouteSuccess(int[] ints) {
        clear();
        //多路径算路成功回调
        HashMap<Integer, AMapNaviPath> paths = mAMapNavi.getNaviPaths();
        for (int i = 0; i < ints.length; i++) {
            AMapNaviPath path = paths.get(ints[i]);
            if (path != null) {
                drawRoutes(ints[i], path,i);
            }
        }
//        NaviLatLng position = paths.get(ints[0]).getCenterForPath();
//        mAMapNaviView.getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(position.getLatitude(),position.getLongitude()),14));
        mAMapNavi.selectRouteId(routeOverlays.keyAt(0));
        mAMapNavi.startNavi(1);
//        setRouteLineTag(paths,ints);
    }

    @Override
    public void notifyParallelRoad(int i) {
    }

    public void  clear (){
        for(int i=0;i<routeOverlays.size();i++){
            RouteOverLay routeOverLay=routeOverlays.valueAt(i);
            System.out.println(routeOverLay);
            routeOverLay.removeFromMap();
        }
        routeOverlays.clear();
    }
    @Override
    public void OnUpdateTrafficFacility(AMapNaviTrafficFacilityInfo[] aMapNaviTrafficFacilityInfos) {
        //更新交通设施信息
    }

    @Override
    public void updateAimlessModeStatistics(AimLessModeStat aimLessModeStat) {
        //更新巡航模式的统计信息
    }


    @Override
    public void updateAimlessModeCongestionInfo(AimLessModeCongestionInfo aimLessModeCongestionInfo) {
        //更新巡航模式的拥堵信息
    }

    @Override
    public void onPlayRing(int i) {

    }


    @Override
    public void onLockMap(boolean isLock) {
        //锁地图状态发生变化时回调
    }

    @Override
    public void onNaviViewLoaded() {
        Log.d("wlx", "导航页面加载成功");
        Log.d("wlx", "请不要使用AMapNaviView.getMap().setOnMapLoadedListener();会overwrite导航SDK内部画线逻辑");
    }

    @Override
    public void onMapTypeChanged(int i) {

    }

    @Override
    public void onNaviViewShowMode(int i) {

    }

    @Override
    public boolean onNaviBackClick() {
        return false;
    }


    @Override
    public void showModeCross(AMapModelCross aMapModelCross) {
    }

    @Override
    public void hideModeCross() {

    }

    @Override
    public void updateIntervalCameraInfo(AMapNaviCameraInfo aMapNaviCameraInfo, AMapNaviCameraInfo aMapNaviCameraInfo1, int i) {

    }

    @Override
    public void showLaneInfo(AMapLaneInfo aMapLaneInfo) {

    }

    @Override
    public void onCalculateRouteSuccess(AMapCalcRouteResult aMapCalcRouteResult) {
//        HashMap<Integer, AMapNaviPath> paths = mAMapNavi.getNaviPaths();
//      int[] routes= aMapCalcRouteResult.getRouteid();
//        for (int i = routes.length-1; i>0 ; i--) {
//            AMapNaviPath path = paths.get(routes[i]);
//            if (path != null) {
//                drawRoutes(routes[i], path,i);
//            }
//        }

    }

    @Override
    public void onCalculateRouteFailure(AMapCalcRouteResult result) {
        //路线计算失败
        Log.e("dm", "--------------------------------------------");
        Log.i("dm", "路线计算失败：错误码=" + result.getErrorCode() + ",Error Message= " + result.getErrorDescription());
        Log.i("dm", "错误码详细链接见：http://lbs.amap.com/api/android-navi-sdk/guide/tools/errorcode/");
        Log.e("dm", "--------------------------------------------");
        Toast.makeText(this, "errorInfo：" + result.getErrorDetail() + ", Message：" + result.getErrorDescription(), Toast.LENGTH_LONG).show();
    }

    @Override
    public void onNaviRouteNotify(AMapNaviRouteNotifyData aMapNaviRouteNotifyData) {

    }

    @Override
    public void onGpsSignalWeak(boolean b) {

    }

    @Override
    public void notifyParallelRoad(AMapNaviParallelRoadStatus aMapNaviParallelRoadStatus) {
        if (aMapNaviParallelRoadStatus.getmElevatedRoadStatusFlag() == 1) {
            Toast.makeText(this, "当前在高架上", Toast.LENGTH_SHORT).show();
            Log.d("wlx", "当前在高架上");
        } else if (aMapNaviParallelRoadStatus.getmElevatedRoadStatusFlag() == 2) {
            Toast.makeText(this, "当前在高架下", Toast.LENGTH_SHORT).show();
            Log.d("wlx", "当前在高架下");
        }

        if (aMapNaviParallelRoadStatus.getmParallelRoadStatusFlag() == 1) {
            Toast.makeText(this, "当前在主路", Toast.LENGTH_SHORT).show();
            Log.d("wlx", "当前在主路");
        } else if (aMapNaviParallelRoadStatus.getmParallelRoadStatusFlag() == 2) {
            Toast.makeText(this, "当前在辅路", Toast.LENGTH_SHORT).show();
            Log.d("wlx", "当前在辅路");
        }
    }

    private void drawRoutes(int routeId, AMapNaviPath path,int index) {
        AMap aMap= mAMapNaviView.getMap();
        RouteOverLay routeOverLay = new RouteOverLay(aMap, path, this);
        routeOverLay.setTrafficLine(true);
        routeOverLay.setLightsVisible(false);
        routeOverLay.setArrowOnRoute(false);
        routeOverLay.setZindex(index==0?1:0);
        routeOverLay.setTransparency(index==0?1f:0.4f);
        routeOverLay.addToMap();
        routeOverlays.put(routeId, routeOverLay);
    }

    /**
     * 路线tag选中设置
     *
     * @param lineOne
     * @param lineTwo
     * @param lineThree
     */
    private void focuseRouteLine(boolean lineOne, boolean lineTwo, boolean lineThree) {
        Log.d("LG", "lineOne:" + lineOne + " lineTwo:" + lineTwo + " lineThree:" + lineThree);
        setLinelayoutOne(lineOne);
        setLinelayoutTwo(lineTwo);
        setLinelayoutThree(lineThree);
    }

    private void initView() {
//        mStartNaviButton = (Button) findViewById(R.id.calculate_route_start_navi);
//        mStartNaviButton.setOnClickListener(this);
//        mRouteLineLayoutOne = (LinearLayout) findViewById(R.id.route_line_one);
//        mRouteLineLayoutOne.setOnClickListener(this);
//        Button cancelButton  =findViewById(R.id.cancel_button);
//        cancelButton.setOnClickListener(this);
//        mRouteLinelayoutTwo = (LinearLayout) findViewById(R.id.route_line_two);
//        mRouteLinelayoutTwo.setOnClickListener(this);
//        mRouteLineLayoutThree = (LinearLayout) findViewById(R.id.route_line_three);
//        mRouteLineLayoutThree.setOnClickListener(this);
//        mRouteViewOne = (View) findViewById(R.id.route_line_one_view);
//        mRouteViewTwo = (View) findViewById(R.id.route_line_two_view);
//        mRouteViewThree = (View) findViewById(R.id.route_line_three_view);
//
//        mRouteTextStrategyOne = (TextView) findViewById(R.id.route_line_one_strategy);
//        mRouteTextStrategyTwo = (TextView) findViewById(R.id.route_line_two_strategy);
//        mRouteTextStrategyThree = (TextView) findViewById(R.id.route_line_three_strategy);
//
//        mRouteTextTimeOne = (TextView) findViewById(R.id.route_line_one_time);
//        mRouteTextTimeTwo = (TextView) findViewById(R.id.route_line_two_time);
//        mRouteTextTimeThree = (TextView) findViewById(R.id.route_line_three_time);
//
//        mRouteTextDistanceOne = (TextView) findViewById(R.id.route_line_one_distance);
//        mRouteTextDistanceTwo = (TextView) findViewById(R.id.route_line_two_distance);
//        mRouteTextDistanceThree = (TextView) findViewById(R.id.route_line_three_distance);
    }
    private void setLinelayoutOne(boolean focus) {
        if (mRouteLineLayoutOne.getVisibility() != View.VISIBLE) {
            return;
        }
        try {
            RouteOverLay overlay = routeOverlays.get((int)mRouteLineLayoutOne.getTag());
            if (focus) {
                routeID = (int) mRouteLineLayoutOne.getTag();
                mAMapNavi.selectRouteId(routeID);
                overlay.setTransparency(ROUTE_SELECTED_TRANSPARENCY);
                mRouteViewOne.setVisibility(View.VISIBLE);
                mRouteTextStrategyOne.setTextColor(getResources().getColor(R.color.light_blue_400));
                mRouteTextTimeOne.setTextColor(getResources().getColor(R.color.light_blue_400));
                mRouteTextDistanceOne.setTextColor(getResources().getColor(R.color.light_blue_400));
            } else {
                overlay.setTransparency(ROUTE_UNSELECTED_TRANSPARENCY);
                mRouteViewOne.setVisibility(View.INVISIBLE);
                mRouteTextStrategyOne.setTextColor(getResources().getColor(R.color.gray_400));
                mRouteTextTimeOne.setTextColor(getResources().getColor(R.color.gray_400));
                mRouteTextDistanceOne.setTextColor(getResources().getColor(R.color.gray_400));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    private void setLinelayoutTwo(boolean focus) {
        if (mRouteLinelayoutTwo.getVisibility() != View.VISIBLE) {
            return;
        }
        try {
            RouteOverLay overlay = routeOverlays.get((int) mRouteLinelayoutTwo.getTag());
            if (focus) {
                routeID = (int) mRouteLinelayoutTwo.getTag();
                mAMapNavi.selectRouteId(routeID);
                overlay.setTransparency(ROUTE_SELECTED_TRANSPARENCY);
                mRouteViewTwo.setVisibility(View.VISIBLE);
                mRouteTextStrategyTwo.setTextColor(getResources().getColor(R.color.light_blue_400));
                mRouteTextTimeTwo.setTextColor(getResources().getColor(R.color.light_blue_400));
                mRouteTextDistanceTwo.setTextColor(getResources().getColor(R.color.light_blue_400));
            } else {
                overlay.setTransparency(ROUTE_UNSELECTED_TRANSPARENCY);
                mRouteViewTwo.setVisibility(View.INVISIBLE);
                mRouteTextStrategyTwo.setTextColor(getResources().getColor(R.color.gray_400));
                mRouteTextTimeTwo.setTextColor(getResources().getColor(R.color.gray_400));
                mRouteTextDistanceTwo.setTextColor(getResources().getColor(R.color.gray_400));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 第三条路线是否focus
     *
     * @param focus focus为true 突出颜色显示，标示为选中状态，为false则标示非选中状态
     */
    private void setLinelayoutThree(boolean focus) {
        if (mRouteLineLayoutThree.getVisibility() != View.VISIBLE) {
            return;
        }
        try {
            RouteOverLay overlay = routeOverlays.get((int) mRouteLineLayoutThree.getTag());
            if (overlay == null) {
                return;
            }
            if (focus) {
                routeID = (int) mRouteLineLayoutThree.getTag();
                mAMapNavi.selectRouteId(routeID);
                overlay.setTransparency(ROUTE_SELECTED_TRANSPARENCY);
                mRouteViewThree.setVisibility(View.VISIBLE);
                mRouteTextStrategyThree.setTextColor(getResources().getColor(R.color.light_blue_400));
                mRouteTextTimeThree.setTextColor(getResources().getColor(R.color.light_blue_400));
                mRouteTextDistanceThree.setTextColor(getResources().getColor(R.color.light_blue_400));
            } else {
                overlay.setTransparency(ROUTE_UNSELECTED_TRANSPARENCY);
                mRouteViewThree.setVisibility(View.INVISIBLE);
                mRouteTextStrategyThree.setTextColor(getResources().getColor(R.color.gray_400));
                mRouteTextTimeThree.setTextColor(getResources().getColor(R.color.gray_400));
                mRouteTextDistanceThree.setTextColor(getResources().getColor(R.color.gray_400));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    private void visiableRouteLine(boolean lineOne, boolean lineTwo, boolean lineThree) {
        setLinelayoutOneVisiable(lineOne);
        setLinelayoutTwoVisiable(lineTwo);
        setLinelayoutThreeVisiable(lineThree);
    }
    private void setRouteLineTag(HashMap<Integer, AMapNaviPath> paths, int[] ints) {
        if (ints.length < 1) {
            visiableRouteLine(false, false, false);
            return;
        }
        int indexOne = 0;
        String stragegyTagOne = paths.get(ints[indexOne]).getLabels();
        setLinelayoutOneContent(ints[indexOne], stragegyTagOne);
        if (ints.length == 1) {
            visiableRouteLine(true, false, false);
            focuseRouteLine(true, false, false);
            return;
        }

        int indexTwo = 1;
        String stragegyTagTwo = paths.get(ints[indexTwo]).getLabels();
        setLinelayoutTwoContent(ints[indexTwo], stragegyTagTwo);
        if (ints.length == 2) {
            visiableRouteLine(true, true, false);
            focuseRouteLine(true, false, false);
            return;
        }

        int indexThree = 2;
        String stragegyTagThree = paths.get(ints[indexThree]).getLabels();
        setLinelayoutThreeContent(ints[indexThree], stragegyTagThree);
        if (ints.length >= 3) {
            visiableRouteLine(true, true, true);
            focuseRouteLine(true, false, false);
        }

    }
    /**
     * 设置第一条线路Tab 内容
     *
     * @param routeID  路线ID
     * @param strategy 策略标签
     */
    private void setLinelayoutOneContent(int routeID, String strategy) {
        mRouteLineLayoutOne.setTag(routeID);
        RouteOverLay overlay = routeOverlays.get(routeID);
        overlay.zoomToSpan();
        AMapNaviPath path = overlay.getAMapNaviPath();
        mRouteTextStrategyOne.setText(strategy);
        String timeDes =utils.getFriendlyTime(path.getAllTime());
        mRouteTextTimeOne.setText(timeDes);
        String disDes = utils.getFriendlyDistance(path.getAllLength());
        mRouteTextDistanceOne.setText(disDes);
    }

    /**
     * 设置第二条路线Tab 内容
     *
     * @param routeID  路线ID
     * @param strategy 策略标签
     */
    private void setLinelayoutTwoContent(int routeID, String strategy) {
        mRouteLinelayoutTwo.setTag(routeID);
        RouteOverLay overlay = routeOverlays.get(routeID);
        AMapNaviPath path = overlay.getAMapNaviPath();
        mRouteTextStrategyTwo.setText(strategy);
        String timeDes =utils.getFriendlyTime(path.getAllTime());
        mRouteTextTimeTwo.setText(timeDes);
        String disDes = utils.getFriendlyDistance(path.getAllLength());
        mRouteTextDistanceTwo.setText(disDes);
    }

    /**
     * 设置第三条路线Tab 内容
     *
     * @param routeID  路线ID
     * @param strategy 策略标签
     */
    private void setLinelayoutThreeContent(int routeID, String strategy) {
        mRouteLineLayoutThree.setTag(routeID);
        RouteOverLay overlay = routeOverlays.get(routeID);
        AMapNaviPath path = overlay.getAMapNaviPath();
        mRouteTextStrategyThree.setText(strategy);
        String timeDes =utils.getFriendlyTime(path.getAllTime());
        mRouteTextTimeThree.setText(timeDes);
        String disDes = utils.getFriendlyDistance(path.getAllLength());
        mRouteTextDistanceThree.setText(disDes);
    }
    private void setLinelayoutOneVisiable(boolean visiable) {
        if (visiable) {
            mRouteLineLayoutOne.setVisibility(View.VISIBLE);
        } else {
            mRouteLineLayoutOne.setVisibility(View.GONE);
        }
    }

    private void setLinelayoutTwoVisiable(boolean visiable) {
        if (visiable) {
            mRouteLinelayoutTwo.setVisibility(View.VISIBLE);
        } else {
            mRouteLinelayoutTwo.setVisibility(View.GONE);
        }
    }

    private void setLinelayoutThreeVisiable(boolean visiable) {
        if (visiable) {
            mRouteLineLayoutThree.setVisibility(View.VISIBLE);
        } else {
            mRouteLineLayoutThree.setVisibility(View.GONE);
        }
    }
    @Override
    public void onClick(View view) {
//        Button cancelButton  =findViewById(R.id.cancel_button);
////        View tabs = findViewById(R.id.calculate_route_strategy_tab);
//        switch (view.getId()){
//            case R.id.cancel_button:
//                finish();
//                break;
////            case R.id.calculate_route_start_navi:
//                view.setVisibility(View.INVISIBLE);
//                cancelButton.setVisibility(View.INVISIBLE);
//                mAMapNaviView.setShowMode(1);
////                tabs.setVisibility(View.INVISIBLE);
//                mAMapNavi.startNavi(1);
////            case R.id.route_line_one:
////                focuseRouteLine(true, false, false);
////                break;
////            case R.id.route_line_two:
////                focuseRouteLine(false, true, false);
////                break;
////            case R.id.route_line_three:
////                focuseRouteLine(false, false, true);
////                break;
//            default:
//                break;
//        }
    }
}
